package com.qihoo.finance.fake.module.msf.facade;

import com.github.pagehelper.PageInfo;
import com.qihoo.finance.fake.module.msf.dao.SystemGeneralDao;
import com.qihoo.finance.fake.module.msf.entity.generate.SystemParamEntity;
import com.qihoo.finance.msf.api.domain.Response;
import com.qihoo.finance.msf.api.sys.domain.MsfParameterDomain;
import com.qihoo.finance.msf.api.sys.domain.SystemParamDomain;
import com.qihoo.finance.msf.api.sys.facade.SystemParamFacade;
import com.qihoo.finance.msf.api.sys.request.SystemParamRequest;
import com.qihoo.finance.msf.core.utils.BeanUtils2;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("systemParamFacadeImpl")
public class SystemParamFacadeImpl implements SystemParamFacade {
    private static final Logger logger = LogManager.getLogger(SystemParamFacadeImpl.class);

    @Resource
    private SystemGeneralDao systemGeneralDao;

    @Override
    public Response<SystemParamDomain> selectByPrimaryKey(int id) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<Integer> updateSystemParam(SystemParamDomain domain) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<PageInfo> selectSysParamListByCondation(SystemParamRequest request) {
        throw new UnsupportedOperationException("unSupport");
    }


    @Override
    public Response<Integer> deleteByPrimaryKey(int id) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<Integer> updateAndValidateRoles(SystemParamDomain domain, List<String> roles) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<Integer> deleteAndValidateRoles(SystemParamDomain systemParamDomain, List<String> roles) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<Integer> insert(SystemParamDomain systemParamDomain) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<List<SystemParamDomain>> queryValidOfModules(List<String> modules) {
        if (org.springframework.util.CollectionUtils.isEmpty(modules)) {
            logger.warn("modules is empty. modules={}", modules);
            return new Response().fail();
        }
        try {
            List<SystemParamEntity> systemParamEntities = systemGeneralDao.querySystemParamValidOfModules(modules);
            List<SystemParamDomain> systemParamDomains = BeanUtils2.copyBeanList(SystemParamDomain.class, systemParamEntities);
            return new Response().success(systemParamDomains);
        } catch (Exception e) {
            logger.error("queryValidOfModules error. modules={}", modules, e);
            return new Response().fail();
        }
    }

    @Override
    public Response<List<MsfParameterDomain>> queryValidOfCodes(List<String> codes) {
        throw new UnsupportedOperationException("unSupport");
    }

    @Override
    public Response<Integer> updateMsfParameter(MsfParameterDomain msfParameterDomain) {
        throw new UnsupportedOperationException("unSupport");
    }


}
